const express = require("express");
const router = express.Router();
const userController = require("../controllers/userController");
// 验证登录状态
const auth = require("../middleware/auth");
// 上传用户头像
const uploadAvatar = require("../middleware/uploadAvatar");

// 创建用户
router.post("/createUser", userController.createUser);
// 用户登录
router.post("/login", userController.loginUser);
// 更新用户信息
router.post("/updateUserInfo", auth, userController.updateUserInfo);
// 获取用户信息
router.get("/getUserInfo", auth, userController.getUserInfo);

// 路由：上传
router.post(
  "/upload/avatar",
  auth,
  uploadAvatar.single("file"),
  userController.uploadAvatar
);

module.exports = router;
